﻿using System;

namespace Xin478.CSWork.Common
{
    [Serializable]
    public class RightInfo
    {
        private bool _read,_add,_modify,_delete;
        public RightInfo(byte rights) { this.Rights = rights; }
        public RightInfo() { }
        public byte Rights 
        { 
            set {
                _read = (value & 8)==8;
                _add = (value & 4)==4;
                _modify = (value & 2)==2;
                _delete = (value & 1)==1;
            }
            get {
                byte i=0;
                if(_read) i += 8;
                if (_add) i += 4;
                if (_modify) i += 2;
                if (_delete) i += 1;
                return i;
            } 
        }

        public bool Read
        {
            set { _read = value; }
            get { return _read; }
        }
        public bool Add
        {
            set { _add = value; }
            get { return _add; }
        }
        public bool Modify
        {
            set { _modify = value; }
            get { return _modify; }
        }
        public bool Delete
        {
            set { _delete = value; }
            get { return _delete; }
        }
    }
}
